<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.11.0.min.js"></script>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<title>Insert title here</title>

<style type="text/css">
body div{border:1px solid red;
}
.main{
	width:70%;height:500px;margin-left: 15%;margin-right: 15%;
}
.inner{width:95%; height:90%;border:1px solid blue;margin-left: 2.4%;margin-right: 2.4%;margin-top: 12px;

}
.inner div{float: left;
}
.left{width:40%;height:90%;margin:10px;float: left;
}
.right{width:50%;height:90%;margin:10px;float: left;
}
.r{width:90%;height:15%;margin-top:10px;
}
#text{height:35%;
}
.btnleft{width:42%;height:70%;margin: 10px;float: left;
}
.btnright{width:42%;height:70%;margin: 10px;float: left;
}

</style>

<!-- 判断是否为登录状态 -->
<script type="text/javascript">
	$(function(){
		$(".btn_add2cart").click(function(){

			if("${user}"==""){
				alert("请先登录");
			}else{
// 				alert($(this).attr('name'));
				var url = "${pageContext.request.contextPath}/Add2CartServlet";
				var param ={
						goodsID:"${goods.goodsID}",
						buyNum:$("#num").val()
				};
				$.get(url, param, function(d){
					if(d.msg=="1"){
						alert("加入成功");
					}else{
						alert("加入失败");
					}
				}, "json");
			}
		});
	});
</script>

<!-- 加减号的js -->
<script type="text/javascript">
	$(function(){
// 		$("#num").change(function(){
// 			alert(51);
// 			if($(this).val()<0){
// 				$(this).val(0);
// 			}
// 		});

		
		$("#add").click(function(){
			var n = $("#num").val();
			n++;
			$("#num").val(n);
		});
		
		$("#reduce").click(function(){
			var n = $("#num").val();
			if(n>1){
				n--;
			}
			$("#num").val(n);
		});
		
		
	});
	
	
	
	
</script>

</head>
<body>
<jsp:include page="/top.jsp"></jsp:include>

<!-- 主要窗口 -->

<div class = "main">
	<div class = "inner">
		<div class="left">
			<img alt="" src="${goods.path }" style = "width:100%; height:100%;">
		</div>
		
		<div class="right">
			<div class="r" id = "name" style = "font-size: 25px;">名字：${goods.goodsName} 
			</div>
			<div class="r"  id = "price"  style = "font-size: 25px;">价格：${goods.goodsPrice }￥
			</div>
			<div class="r" id = "btn">
				<div class= "btnleft">
					<div style="margin-right: 5px;">数量:</div>
					<input type = "button" value = "-" id = "reduce">
					<input type = "text" value = "1" id = "num" readonly="readonly" style = "width:30px;" >
					<input type = "button" id = "add" value = "+">
				</div>
				<div class= "btnright">
					<input class = "btn_add2cart" type = "button" value="加入购物车" style = "width:100%; height:100%;font-size: 25px;">
				</div>
			</div>
			<div class="r" id = "text" style  = "padding: 8px;" >&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp根据植物本身的特点及人类认识植物的规律，囊括了植物的生活、植物的种类、植物的文化等各方面的内容，以详尽的资料、简洁的文字、生动的图片向读者展示了一个栩栩如生的植物世界。
			</div>
		</div>
	</div>
</div>


</body>
</html>